<fieldset>
<legend>Manage Merchant Accounts</legend>
<?php
/*
+--------------------------------------------------------------------------
|   Manage accounts - Extra feature
|	Sep 7th 2009, edited by Kien Tran
|   ========================================

+--------------------------------------------------------------------------
*/
// checks to see if password session is set
// if not redirects to ../admin/
if($_SESSION['loggedIn'] == 0 && !isset($adminPage)){
include('../includes/auth.inc.php');
}
include_once '../includes/models/Click.php';
include_once '../includes/models/Account.php';
$click = new Click();
$account = new Account();

if (isset($_GET['accId']) && $_GET['accId'] > 0)
{
	$currAccount = $account->getById($_GET['accId']);
	unset($currAccount['accPassword']);
	echo 'Detailed Information for user "'.$currAccount['accUsername'].'":<br/>';
	echo '<table cellpadding="5" cellspacing="0" border="0" width="80%">';
	foreach ($currAccount as $key => $value)
	{
		echo '<tr>';
		echo '<td align="right"><b>'.substr($key,3).':</b> </td>'.'<td>'.$value.'</td>';
		echo '</tr>';
		
	}
	echo '</table>';
	echo 'Current Activities: no news (implement later)<br />';
}
else 
{
	?>
	
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
	<tr class="titlebar" bgcolor="Gray">
		<td>ID</td>
		<td>Username</td>
		<td>Name</td>
		<td>Email</td>
		<td>Website URL</td>
		<td>Payments</td>
		<td>Created Date</td>
	</tr>
	<?php
	
	$allAccounts = $account->getAll();
	$count = 0;
	foreach ($allAccounts as $item)
	{
		if ($count % 2 == 1)
			echo '<tr bgcolor="Silver">';
		else 
			echo '<tr>';
		echo '<td>'.$item['accId'].'</td>';
		echo '<td>'.'<a href="'.$installDir['value'].'admin/index.php?ad=ac&accId='.$item['accId'].'">'.$item['accUsername'].'</a></td>';
		echo '<td>'.$item['accFirstName'].' '.$item['accLastName'].'</td>';
		echo '<td>'.$item['accContactEmail'].'</td>';
		echo '<td>'.$item['accWebsiteUrl'].'</td>';
		echo '<td>'.'$100'.'</td>';
		echo '<td>'.$item['accCreated'].'</td>';
		echo '</tr>';
		++$count;
	}
	
	?>
	</table>
<?php
}
?>

</fieldset>